package study.thread.basic;

/*
 * sleep有两个重载版本：1.以毫秒指定睡眠时间；2.以纳秒指定睡眠时间；
 * Thread.sleep()使当前线程的执行暂停一段时间，该方法不会放弃CPU之外的其他资源；
 */
public class SleepTest {

	public static void main(String[] args) {
		
		String strs[] = {"one","two","three","four"};
		
		long start = System.nanoTime();
		System.out.println("start====> "+start);
		
		for (int i = 0; i < strs.length; i++) {
			
			try {
				
				System.out.println(strs[i]);
				
				//休眠主线程
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
		long end = System.nanoTime();
		System.out.println("end====> "+end);
		
		System.out.println("总时间："+(end-start)/1000000000+"s");
	}

}
